package com.chixing.day14_map;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Iterator;

public class StudentTest {
    public static void main(String[] args) {
        ArrayList<Student> arraylist = new ArrayList<>();

        arraylist.add(new Student(1001,"Smith","计算机",20, LocalDate.of(2010,9,1)));
        arraylist.add(new Student(1002,"Peter","英语",23,LocalDate.of(2011,9,2)));
        arraylist.add(new Student(1003,"Allen","物理",34, LocalDate.of(2013,9,2)));
        arraylist.add(new Student(1004,"Linda","英语",23, LocalDate.of(2011,9,3)));
        //arraylist.add(new Student(1005,"Jerry","null",25, LocalDate.of(2012,9,2)));

        ArrayList<Student> arrayList1 = new ArrayList<>();
        for (int i=0;i<arraylist.size();i++){
            for (int j=0;j<arraylist.size()-i-1;j++){
                if (arraylist.get(j).getStuTime().isAfter(arraylist.get(j+1).getStuTime())){
                    Student temp;
                    temp = arraylist.get(j);
                    arraylist.set(j,arraylist.get(j+1));
                    arraylist.set(j+1,temp);
                }
            }
        }
        System.out.println(arraylist);

    }
}
